<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>

<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,  initial-scale=1.0">
<title>个人中心</title>
<script type="text/javascript"  src="${pageContext.request.contextPath }/resource/js/jquery-3.2.1.js"></script>
<script type="text/javascript"  src="${pageContext.request.contextPath }/resource/js/bootstrap.js"></script>
<link rel="stylesheet" href="${pageContext.request.contextPath }/resource/css/bootstrap.css">
     <link rel="stylesheet"  href="${pageContext.request.contextPath }/resource/kindeditor/themes/default/default.css" />
     <link rel="stylesheet"  href="${pageContext.request.contextPath }/resource/kindeditor/plugins/code/prettify.css" />
     <script charset="utf-8"  src="${pageContext.request.contextPath }/resource/kindeditor/kindeditor.js"></script>
     <script charset="utf-8"  src="${pageContext.request.contextPath }/resource/kindeditor/lang/zh-CN.js"></script>
     <script charset="utf-8"  src="${pageContext.request.contextPath }/resource/kindeditor/plugins/code/prettify.js"></script>
     <script>
           KindEditor.ready(function(K) {
                window.editor1 =  K.create('textarea[name="content1"]', {
                      cssPath :  '/resource/kindeditor/plugins/code/prettify.css',
                      uploadJson :  '/resource/kindeditor/jsp/upload_json.jsp',
                      fileManagerJson :  '/resource/kindeditor/jsp/file_manager_json.jsp',
                      allowFileManager : true,
                      afterCreate : function() {
                           var self = this;
                           K.ctrl(document, 13, function() {
                                 self.sync();
                                 document.forms['example'].submit();
                           });
                           K.ctrl(self.edit.doc, 13, function() {
                                 self.sync();
                                 document.forms['example'].submit();
                           });
                      }
                });
                prettyPrint();
           });
     </script>
</head>
<body>
	
	<div class="container">
           <!-- 上方展示区 -->
           <div>
           		<!-- logo 图片 -->
                <a href="${pageContext.request.contextPath }/"><img alt=""  src="${pageContext.request.contextPath }/resource/pic/logo-admin.jpg"></a>
                
                <div class="float-right align-items-center" >
                      <!-- 右侧的个人中心和退出按钮 -->
                      <!-- 如果已经登录，则显示个人中心和退出 -->
                           <c:if test="${LOGIN_USER!=null }">
                                 你好，<b>${LOGIN_USER.nickname  }</b>
                                 <input class="btn btn-primary  btn-sm" type="button" onclick="toCenter()"  value="${LOGIN_USER.role==0?'个人中心':'管理员中心' }">
                                 <input class="btn btn-primary  btn-sm" type="button" onclick="logout()" value="退出">
                           </c:if>
                           
                           <!-- 如果没有登录，则显示登录和注册按钮  -->
                           <c:if test="${LOGIN_USER==null }">
                                 <input class="btn btn-primary  btn-sm" type="button" onclick="toLogin()" value="登录">
                                 <input class="btn btn-primary  btn-sm" type="button" onclick="toRegister()" value="注册">
                           </c:if>
                </div>

           </div>
           <hr>
           
           <!-- 下方展示区：静态页面内容：4个页签 -->
           <div class="row">
                <!-- 左侧导航 -->
                <div class="col-md-2">
                
                      <div class="list-group text-center">
                        <a href="#" class="list-group-item  list-group-item-action active"
                        data="${pageContext.request.contextPath }/my/articles" >我的文章</a>
                        
                        <a href="#" class="list-group-item  list-group-item-action"
                        data="${pageContext.request.contextPath }/my/publish">发布文章</a>
                        
                        <a href="#" class="list-group-item  list-group-item-action"
                        data="${pageContext.request.contextPath }/my/collect">我的收藏</a>
                        
                        <a href="#" class="list-group-item  list-group-item-action"
                        data="${pageContext.request.contextPath }/my/comment">我的评论</a>
                      </div>
                </div>
                
                <!-- 右侧页面展示 -->
                <div class="col-md-10">
                      <div id="center">
                           <!-- 内嵌页面资源（.jsp） -->
                      </div>
                </div>
           </div>
     
     </div>

</body>
<script type="text/javascript">


//使用文档就绪函数，
$(function(){
      
      //加载"我的文章"页面
      $("#center").load("${pageContext.request.contextPath }/my/articles");
      
      //绑定超链接事件
      $("a").click(function(){
           //获取标签中的data属性
           var url = $(this).attr("data");
           
           //加载对应页面
           $("#center").load(url);
           
           //将原来选中的变成未选中
           $(".active").removeClass("active");
           
           //修改class属性，实现选中状态
           $(this).addClass("active");
           
      })
})



	// 跳转到注册页面
	function toRegister() {
		location = "${pageContext.request.contextPath }/user/toRegister"
	}
	
	// 跳转到登录页面
	function toLogin() {
		location = "${pageContext.request.contextPath }/user/toLogin"
	}
	
	// 注销
	function logout() {
		location = "${pageContext.request.contextPath }/user/logout"
	}
	
	//分页参数
    function goPage(pageNum){
          location="${pageContext.request.contextPath }/index?pageNum="+pageNum;
    }
	
	
    // 去个人中心：function函数
    function toCenter(){
          //获取角色role值
          var role = '${LOGIN_USER.role}';

          //判断role值
          if(role == 0){
               //普通用户
               location="${pageContext.request.contextPath }/my/";
          }else{
               //超级管理员
               location="${pageContext.request.contextPath }/admin/";
          }
    }
</script>

</html>